import React, { Component } from 'react';
import { withRouter, NavLink } from 'react-router-dom'
import '../asserts/css/common.css'
import rules from '../router/rules'
import RouterView from '../router/index.js'
class Layout extends Component {
    state = {
        isTrue:true
    }
    UNSAFE_componentWillMount()
    {
        let whiteList = ['/cart',"/cate",'/goodslist','/index','/uncenter']
        if(!whiteList.includes(this.props.location.pathname) )
        {
            this.setState({isTrue:false})
        }
    }
    render() {
        let {isTrue} = this.state
        return (
            <>
                 <RouterView routes={rules}></RouterView>
                {
                     isTrue ? <ul className="tabbar">
                    <li className="icon icon-home">
                        <NavLink to="/index">商城</NavLink>
                    </li>
                    <li className="icon icon-cate">
                        <NavLink to="/cate">分类</NavLink>
                    </li>
                    <li className="icon icon-cart">
                        <span className="badge">5</span>
                        <NavLink to="/cart">购物车</NavLink>
                    </li>
                    <li className="icon icon-user">
                        <NavLink to="uncenter">我的</NavLink>
                    </li>
                </ul> : ""
 
                }
                
            </>
        );
    }
}

export default withRouter(Layout);